<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
        //数组：一组数据
        let arr = [45,78,21,456,-78.,0];
        console.log(arr[2]);    //打印21
        console.log(arr);       //打印对象object
        //遍历数组
        for(let i=0;i<arr.length;i++){
            console.log(arr[i]);
        }
    
    
    
        //找出成绩score中的最高分，并求平均分数。score[45,78,89,94,63,55,80,74];
    //     let score = [45,78,89,94,63,55,80,74];
    //     let sum = 0
    //     let max = min=score[0];
    //     for(let i=1;i<score.length;i++){
    //         sum+=score[i];
    //     if(score[i]>max){
    //         max=score[i];
    //     }
    //     if(score[i]<min){
    //         min = score[i];
    //     }
    // }
    // console.log(sum/score.length);
    // console.log(max);
    // console.log(min);
    
    
    let score = [45,78,89,94,63,55,80,74];
    let max=score[0],avg,sum=0;
    for(let i=0;i<score.length;i++){
        if(score[i]>max){
            max=score[i];
        }
        sum=sum+score[i];
    }
    avg=sum/score.length;
    console.log('最高分是'+max);
    console.log('平均分是'+avg);
    
    //
    console.log(score.length);
    score[47]=90;
    console.log(score.length);
    console.log(score);
    //
console.log(score.length);
score[47]=90;
console.log(score.length);
console.log(score);



let arr1= [1,3,26,5,4];
    let temp;
    //两层循环
    for(let i=0;i<arr1.length;i++){
        for(let j=0;j<arr1.length;j++){
            if(arr[j]>arr1[j+1]){
                temp=arr1[j];
                arr1[j]=arr1[j+1];
                arr1[j+1]=temp;
            }
        }
    }
    console.log(arr1);
    let arr2=[[1,2,3],[4,5,6],[7,8,9]];
    console.log(arr2[0][0]);    //1
    console.log(arr2[0][1]);    //2
    console.log(arr2[0][2]);

    //循环方式遍历二维数组
    </script>
</html>